﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="Events.aspx.cs" Inherits="TicketingCompany.Events" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ContentPlaceHolderID="MainContent" runat="server">
    <asp:ScriptManager ID="ScriptManager" runat="server">
    </asp:ScriptManager>

    <asp:UpdatePanel runat="server">
        <ContentTemplate>
            <asp:Button ID="ButtonOpenCreateEventPanel" Text="Create Event" runat="server" OnClick="ButtonOpenCreateEventPanel_Click" />
            <asp:Panel ID="PanelCreateEvent" Visible="false" runat="server">
                Location:
                <asp:DropDownList ID="DropDownListLocations" runat="server" DataSourceID="EntityDataSourceLocations"
                    DataTextField="Name" DataValueField="LocationID">
                </asp:DropDownList>
                <br />
                <asp:EntityDataSource ID="EntityDataSourceLocations" runat="server" ConnectionString="name=TicketingCompanyEntities"
                    DefaultContainerName="TicketingCompanyEntities" EnableFlattening="False" EntitySetName="Locations"
                    Select="it.[LocationID], it.[Name]">
                </asp:EntityDataSource>
                Category:
                <asp:DropDownList ID="DropDownListCategories" runat="server" DataSourceID="EntityDataSourceCategories"
                    DataTextField="Name" DataValueField="CategoryID">
                </asp:DropDownList>
                <br />
                <asp:EntityDataSource ID="EntityDataSourceCategories" runat="server" ConnectionString="name=TicketingCompanyEntities"
                    DefaultContainerName="TicketingCompanyEntities" EnableFlattening="False" EntitySetName="Categories"
                    Select="it.[CategoryID], it.[Name]">
                </asp:EntityDataSource>
                Title:
                <asp:TextBox ID="TextBoxEventTitle" runat="server" />
                <asp:Label ID="LabelInvalidTitle" Text="The title should be between 1 and 150 characters." runat="server"
                    ForeColor="Red" Visible="false" />
                <br />
                Price:
                <asp:TextBox ID="TextBoxPrice" runat="server" />
                <br />
                <telerik:RadCalendar ID="RadCalendarEventDate" EnableMultiSelect="false" runat="server">
                </telerik:RadCalendar>
                <br />
                <asp:Button ID="ButtonCreateEvent" Text="Create" runat="server" OnClick="ButtonCreateEvent_Click" />
                <asp:Label ID="LabelErrorCreate" ViewStateMode="Disabled" Text="Please fill all the inputs"
                    runat="server" ForeColor="Red" Visible="false" />
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:Label ID="LabelError" Text="It seems there are Users signed for that event" runat="server" Visible="false" ForeColor=Red/>
    <asp:ListView ID="ListViewEvents" runat="server" DataKeyNames="EventID" DataSourceID="EntityDataSource">
        <ItemSeparatorTemplate>
            <hr />
        </ItemSeparatorTemplate>
        <ItemTemplate>
            <li style="background-color: #DCDCDC; color: #000000;">Title:
                <asp:Label ID="TitleLabel" runat="server" Text='<%# SafeEval("Title") %>' />
                <br />
                Category:
                <asp:Label ID="CategoryIDLabel" runat="server" Text='<%# GetCategoryByID() %>' />
                <br />
                Location:
                <asp:Label ID="LocationIDLabel" runat="server" Text='<%# GetLocationByID() %>' />
                <br />
                DateTime:
                <asp:Label ID="DateTimeLabel" runat="server" Text='<%# Eval("DateTime") %>' />
                <br />
                Price:
                <asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("Price") %>' />
                <br />
                <asp:Button Text="Edit" runat="server"  OnCommand="ButtonEdit_Command" CommandArgument='<%# Eval("EventID") %>' />                
                <asp:Button Text="Delete" runat="server"  OnCommand="ButtonDelete_Command" CommandArgument='<%# Eval("EventID") %>' />                
            </li>
        </ItemTemplate>
        <LayoutTemplate>
            <ul id="itemPlaceholderContainer" runat="server" style="font-family: Verdana, Arial, Helvetica, sans-serif;">
                <li runat="server" id="itemPlaceholder" />
            </ul>
            <div style="text-align: center; background-color: #CCCCCC; font-family: Verdana, Arial, Helvetica, sans-serif;
                color: #000000;">
                <asp:DataPager ID="DataPagerLocation" runat="server">
                    <Fields>
                        <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False"
                            ShowPreviousPageButton="False" />
                        <asp:NumericPagerField />
                        <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False"
                            ShowPreviousPageButton="False" />
                    </Fields>
                </asp:DataPager>
            </div>
        </LayoutTemplate>
    </asp:ListView>

    <asp:EntityDataSource ID="EntityDataSource" runat="server" ConnectionString="name=TicketingCompanyEntities"
        DefaultContainerName="TicketingCompanyEntities" EnableDelete="True" EnableFlattening="False"
        EntitySetName="Events">
    </asp:EntityDataSource>
</asp:Content>
